package com.dzzw.Servlet.VoteServlet;

import com.dzzw.Dao.VoteDao;
import com.dzzw.Model.Vote;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/VoteAddServlet")
public class VoteAddServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    VoteDao voteDao = new VoteDao();
    public VoteAddServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String vote_title = request.getParameter("vote_title");
        String vote_introduce = request.getParameter("vote_introduce");
        Vote vote = new Vote();
        vote.setVote_title(vote_title);
        vote.setVote_introduce(vote_introduce);
        voteDao.VoteAdd(vote);
        response.sendRedirect("/View/SelectAllDetail.jsp");
    }
}
